<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>创建自定义对象</title>
    <script>
        //构造函数(函数名首字母大写)
        function Person(name,age){
            this.name = name;
            this.age = age;
            this.sayHello = function(){
                alert(this.name);
            }
        }

        //此时创建出来的P和this 的关系：p == this
        var p = new Person("小明",23);
        p.sayHello();

        //此时，this会指向window
        Person();

        //普通函数(函数名首字母小写)
        function  person() {

        }
    </script>
</head>
<body>

</body>
</html>